package com.docted.design.pattern.prototype;

/**
 * @author DoCted
 * @since v1.0 2018/3/7
 */
public class CloneTest {


    public static void main(String[] args) throws CloneNotSupportedException {

        Prototype prototype = new Prototype();

        prototype.setName("DoCted");

        prototype.getList().add("AAAAAAAA");
        prototype.getList().add("BBBBBBB");
        prototype.getList().add("CCCCCCCC");

        Prototype p1  = (Prototype) prototype.clone();


        //先拷贝。List属性直接将地址复制给新对象。
        //此时是不符合克隆模式
        System.out.println(prototype.getList().hashCode());
        System.out.println(p1.getList().hashCode());


    }
}
